package org.faradel.pharmapp.entities;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.springframework.stereotype.Component;

/**
 * The persistent class for the PatientOrder database table.
 * 
 */
@Entity
@Component("patientOrder")
@Table(name = "PatientOrder")
public class PatientOrder implements Serializable
{
    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "patient_order_id")
    private int patientOrderId;

    @Column(name = "last_modified")
    private Date lastModified;

    @Column(name = "order_method")
    private String orderMethod;

    @Column(name = "patient_first_name")
    private String patientFirstName;

    @Column(name = "patient_id")
    private int patientId;

    @Column(name = "patient_last_name")
    private String patientLastName;

    @Column(name = "payment_method")
    private String paymentMethod;

    private String status;

    @Column(name = "total_cost")
    private BigDecimal totalCost;

    @Column(name = "user_last_modified")
    private int userLastModified;

    @Column(name = "order_date")
    private Date orderDate;

    @Column(name = "closed_date")
    private Date closedDate;

    public Date getOrderDate()
    {
        return orderDate;
    }

    public void setOrderDate(Date orderDate)
    {
        this.orderDate = orderDate;
    }

    public Date getClosedDate()
    {
        return closedDate;
    }

    public void setClosedDate(Date closedDate)
    {
        this.closedDate = closedDate;
    }

    // bi-directional many-to-one association to PrescriptionOrder
    @OneToMany(mappedBy = "patientOrder", fetch = FetchType.LAZY)
    private List<PrescriptionOrder> prescriptionOrders;

    public PatientOrder()
    {
    }

    public int getPatientOrderId()
    {
        return this.patientOrderId;
    }

    public void setPatientOrderId(int patientOrderId)
    {
        this.patientOrderId = patientOrderId;
    }

    public Date getLastModified()
    {
        return this.lastModified;
    }

    public void setLastModified(Date lastModified)
    {
        this.lastModified = lastModified;
    }

    public String getOrderMethod()
    {
        return this.orderMethod;
    }

    public void setOrderMethod(String orderMethod)
    {
        this.orderMethod = orderMethod;
    }

    public String getPatientFirstName()
    {
        return this.patientFirstName;
    }

    public void setPatientFirstName(String patientFirstName)
    {
        this.patientFirstName = patientFirstName;
    }

    public int getPatientId()
    {
        return this.patientId;
    }

    public void setPatientId(int patientId)
    {
        this.patientId = patientId;
    }

    public String getPatientLastName()
    {
        return this.patientLastName;
    }

    public void setPatientLastName(String patientLastName)
    {
        this.patientLastName = patientLastName;
    }

    public String getPaymentMethod()
    {
        return this.paymentMethod;
    }

    public void setPaymentMethod(String paymentMethod)
    {
        this.paymentMethod = paymentMethod;
    }

    public String getStatus()
    {
        return this.status;
    }

    public void setStatus(String status)
    {
        this.status = status;
    }

    public BigDecimal getTotalCost()
    {
        return this.totalCost;
    }

    public void setTotalCost(BigDecimal totalCost)
    {
        this.totalCost = totalCost;
    }

    public int getUserLastModified()
    {
        return this.userLastModified;
    }

    public void setUserLastModified(int userLastModified)
    {
        this.userLastModified = userLastModified;
    }

    public List<PrescriptionOrder> getPrescriptionOrders()
    {
        return this.prescriptionOrders;
    }

    public void setPrescriptionOrders(List<PrescriptionOrder> prescriptionOrders)
    {
        this.prescriptionOrders = prescriptionOrders;
    }

    public PrescriptionOrder addPrescriptionOrder(PrescriptionOrder prescriptionOrder)
    {
        getPrescriptionOrders().add(prescriptionOrder);
        prescriptionOrder.setPatientOrder(this);

        return prescriptionOrder;
    }

    public PrescriptionOrder removePrescriptionOrder(PrescriptionOrder prescriptionOrder)
    {
        getPrescriptionOrders().remove(prescriptionOrder);
        prescriptionOrder.setPatientOrder(null);

        return prescriptionOrder;
    }

}